export default{
    namespaced: true,
    state:{
        address:uni.getStorageSync('address') || '',
        token:uni.getStorageSync("token"),
        routeInfo:null//路由信息
    },
    getters:{
        getAddress(state){
            return state.address
        },
        getAddressDetail(state){
            return state.address&& `${state.address.provinceName}${state.address.cityName}${state.address.countyName}${state.address.detailInfo}`
        },
        getToken(state){
            return state.token
        },
        // 获取路由信息
        getRouteInfo(state){
            return state.routeInfo
        }
    },
    mutations:{
        setAddress(state,address){
            state.address=address
            // 把地址信息保存到本地
            uni.setStorageSync('address', address)
        },
        setToken(state,token){
            // 保存token
            state.token=token
            // 保存到本地
            uni.setStorageSync('token', token)
        },
        // 保存路由
        setRouteInfo(state,routeInfo){
            state.routeInfo=routeInfo
        }
    }
}